<?
#####################################################
#  COPYRIGHT NOTICE
#####################################################
# In the following statements, the term "this 
# program" refers to all files associated with the
# execution and distribution of Adtrackz.
#
# This Program is Copyright 2004 Jonah Klimack.
# All Rights Reserved. 
#
# Selling the code for this program, modifying 
# and/or redistributing the code for this program
# in part or in whole over the Internet or in any 
# other medium is expressly forbidden. Violators
# will be prosecuted to the fullest extent of the law
# Copyright and header information may not be
# modified.
#
# This program is distributed "as is" and without 
# warranty of any kind, either express or implied.
# In no event shall the liability of Jonah Klimack 
# for any damages, losses and/or causes of 
# action exceed the total amount paid by the 
# user for this software.		
#####################################################
# DO NOT MODIFY ANYTHING IN THIS FILE
#####################################################


require "header.php";

?>
<p class="small" align="left">
Campaigns > Add New And Cloak
</p>
<p class="heading">
Add A New Campaign And Cloak
</p>
<p> Fill out this simple form to add a new campaign and AdTrackzGold will create a 
  campaign for you and supply you with your tracking url. Place this url in your 
  ads and you will be able to track the source of your clicks and sales. <a href="http://www.adtrackzgold.com/manual" target=_new>Click 
  here</a> to learn how to use subcampaigns. </p>
<p> <a href="http://www.adtrackzgold.com/manual" target=_new>Click here</a> to 
  learn how to track actions and sales for any affiliate program you may be promoting. 
</p>
<br>
<?

if ($submit)
{
	$startdate = $fyear."-".$fmonth."-".$fday." 00:00:00";
	$enddate = $tyear."-".$tmonth."-".$tday." 00:00:00";

	//check variables
	if (strlen($adcode) > 100)
		error("adcode must be less than 100 characters.");
	elseif (!$adcode)
		error("ad code is a required field.");
	elseif (preg_match("/(\W+|\s+)/", $adcode, $matches))
		error("Ad code must contain letters,digits or and underscore character only.");
	elseif (strlen($url) > 255)
		error("Url must be less than 255 characters.");
	elseif (!$url)
		error("Url is a required field.");
	elseif (!preg_match("/(http|https):\/\//", $url))
		error("Url is not valid.");
	elseif (!preg_match("/\b\d+\b/", $cost))
		error("Cost must be in numerical format.");
	elseif (earlier_date($startdate,$enddate) == $enddate)
		error("Start date must be earlier than end date.");
	elseif ($recur && $ppc)
		error("Please select recurring or ppc. Both can't be selected at the same time.");
	elseif ($recur && (!$recurdays || !$repeat))
		error("Recurring cost and repeating cost must be filled out if recurring is selected.");
	elseif ($recurdays && !preg_match("/\b\d+\b/", $recurdays))
		error("Recurring days must be an integer value.");
	elseif ($repeat && !preg_match("/\b\d+\b/", $repeat))
		error("Repeat must be an integer value.");
	elseif ($recur && $cost == "0.00")
		error("You must enter a cost if you select recurring.");
	elseif ($ppc && $cost == "0.00")
		error("You must enter a cost if you select ppc.");
	elseif (mysql_num_rows(mysql_query("select * from adtrackz_campaigns where adcode='$adcode'")))
		error("That adcode has already been taken. Please choose another.");
	elseif ($merchant && $purpose != "affiliate")
		error("If you entered something in the merchant field, you must select 'Affiliate Link' as the purpose of your campaign.");
	else
	{
		if ($ppc)
			$ppc = 1;
		
		if ($group == "default")
			$groupID = "0";
		else
			$groupID = mysql_fetch_row(mysql_query("select ID from adtrackz_groups where ID='$group'"));

		$adcode = trim($adcode);
		$adcode = strtolower($adcode);		

		mysql_query("insert into adtrackz_campaigns values('','$groupID[0]','$adcode','$url','$cost','$startdate','$enddate','$description','$purpose','$recurdays','$repeat','$ppc')");

		//add split test option
		$newcampaignID = mysql_fetch_row(mysql_query("select ID from adtrackz_campaigns where adcode='$adcode'"));
		mysql_query("insert into adtrackz_campaigns_st values ('$newcampaignID[0]', '$st')");

		alert ("The new campaign $adcode has been added successfully!<br><br>Select below for your new tracking url:<br> <textarea cols=50 rows=2>http://$domain/$udirectory/go.php?c=$adcode</textarea><br><br>Click this link to test it: <a href=http://$domain/$udirectory/go.php?c=$adcode target=_new>http://$domain/$udirectory/go.php?c=$adcode</a>.");
		echo "<br><br>";

		unset($adcode, $group, $purpose, $url, $cost, $ppc, $recurdays, $repeat, $fmonth, $fday, $fyear, $tmonth, $tday, $tyear, $description, $optcontact, $opturl, $optemail, $optphone, $optnotes, $st);

		##################################
		//CODE FOR CLOAK
		##################################
		if ($yescloak)
		{
			//get latest cID
			$cID = $newcampaignID[0];

			if (!$filename)
				error("The Cloak was not created because you did not enter a filename.");
			elseif($encrypt && !$merchant_url)
				error("You must enter a merchant url if you choose to encrypt your redirect page. The cloak was not created.");
			elseif(mysql_fetch_row(mysql_query("select * from adtrackz_redirects where filename='$ftpfile'")))
				error("You have already created $wwwfile. Please delete it by clicking on View/Edit under the cloak menu and try again.");
			else
			{
				//CREATE CONTENT OF FILE
				//cloaker (keep url on top) - simply a framed page, visitors can view source
				//encrypt - a framed page, but when visitor views source, they get hex code
				//normal - a normal html redirect page

				$campaign_name = mysql_fetch_row(mysql_query("select adcode from adtrackz_campaigns where ID='$cID'"));
				$tracking_url = "http://".$domain."/".$udirectory."/go.php?c=$campaign_name[0]&s=$sub"; 

				//need ftpfile, wwwfile for saving to mysql, and display, respectively
				//need wwwfile_embed for cloak && encrypt
				if ($directory)
				{
					$ftpfile = $basedir."/".$directory."/".$filename.$extension;
					$wwwfile = "http://".$domain."/".$directory."/".$filename.$extension;
					$wwwfile_embed = "http://".$domain."/".$directory."/".$filename."_embed".$extension;
				}
				else 
				{
					$ftpfile = $basedir."/".$filename.$extension;
					$wwwfile = "http://".$domain."/".$filename.$extension;
					$wwwfile_embed = "http://".$domain."/".$filename."_embed".$extension;
				}

				if ($sticky && $encrypt)
				{
					$contents = '
					<HTML>
					<HEAD>
						<TITLE>'.$title.'</TITLE>
					</HEAD>
					<frameset border=0 frameBorder=0 rows=100%,* marginbottom=0 margintop=0 marginright=0 marginleft=0>
						<FRAME name=_main src="'.$wwwfile_embed.'" target="_main"  scrolling="yes" noresize frameborder="no" framespacing="0">
						<frame border=0 noresize>
						<NOFRAMES>
							<body>
								<p>This page uses frames, but your browser doesn\'t support them.</p>
								<p><a href="'.$tracking_url.'">Click Here to Continue...</a></p>
							</body>
						</NOFRAMES>
					</FRAMESET>
					</HTML>
					';
					//echo "<form><textarea name=a rows=10 cols=30>$contents</textarea></form>";

					//EMBEDED SOURCE
					$src = "<embed src=\"$tracking_url\" width=\"2\" height=\"2\"></embed><meta http-equiv=\"Refresh\" content=\"0;url=$merchant_url\">";

					//echo "<form><textarea name=b rows=10 cols=30>$src</textarea></form>";

					//ord the src
					for ($i=0; $i < strlen($src); $i++)
					   $src2 .= dechex(ord(substr($src,$i))); 
					$src2 = strtoupper($src2);

					//echo "<form><textarea name=b rows=10 cols=30>$src2</textarea></form>";

					$contents_embed = '
					<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
					<HTML>
					<HEAD>
					<TITLE> One Moment Please... </TITLE>
					</HEAD>
					<BODY>
					<SCRIPT language=Javascript>	q="'.$src2.'";r="683D22223B666F72286A323D303B6A323C712E6C656E6774683B6A322B2B297B6966286A3225323D3D3029682B3D2225223B682B3D712E636861724174286A32293B7D646F63756D656E742E777269746528756E657363617065286829293B683D22223B";eval(unescape("%67%3D%22%22%3B%66%6F%72%28%6A%3D%30%3B%6A%3C%72%2E%6C%65%6E%67%74%68%3B%6A%2B%2B%29%7B%69%66%28%6A%25%32%3D%3D%30%29%67%2B%3D%22%25%22%3B%67%2B%3D%72%2E%63%68%61%72%41%74%28%6A%29%3B%7D%65%76%61%6C%28%75%6E%65%73%63%61%70%65%28%67%29%29%3B%67%3D%22%22%3B"));
					</script>
					</BODY>
					</HTML>
					';

					//echo "<form><textarea name=a rows=10 cols=30>$contents</textarea></form>";

				}
				elseif ($sticky)
				{
					//create framed page? or...............
					$contents = '
					<HTML>
					<HEAD>
						<TITLE>'.$title.'</TITLE>
					</HEAD>
					<frameset border=0 frameBorder=0 rows=100%,* marginbottom=0 margintop=0 marginright=0 marginleft=0>
						<FRAME name=_main src="'.$tracking_url.'" target="_main"  scrolling="yes" noresize frameborder="no" framespacing="0">
						<frame border=0 noresize>
						<NOFRAMES>
							<body>
								<p>This page uses frames, but your browser doesn\'t support them.</p>
								<p><a href="'.$tracking_url.'">Click Here to Continue...</a></p>
							</body>
						</NOFRAMES>
					</FRAMESET>
					</HTML>
					';
					//echo "<form><textarea name=a rows=10 cols=30>$contents</textarea></form>";
				}
				elseif ($encrypt)
				{
					//purpose: to protect affiliate links

					$src = "<embed src=\"$tracking_url\" width=\"2\" height=\"2\"></embed><meta http-equiv=\"Refresh\" content=\"0;url=$merchant_url\">";

					//echo "<form><textarea name=b rows=10 cols=30>$src</textarea></form>";

					//ord the src
					for ($i=0; $i < strlen($src); $i++)
					   $src2 .= dechex(ord(substr($src,$i))); 
					$src2 = strtoupper($src2);

					//echo "<form><textarea name=b rows=10 cols=30>$src2</textarea></form>";

					$contents = '
					<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
					<HTML>
					<HEAD>
					<TITLE> One Moment Please... </TITLE>
					</HEAD>
					<BODY>
					<SCRIPT language=Javascript>	q="'.$src2.'";r="683D22223B666F72286A323D303B6A323C712E6C656E6774683B6A322B2B297B6966286A3225323D3D3029682B3D2225223B682B3D712E636861724174286A32293B7D646F63756D656E742E777269746528756E657363617065286829293B683D22223B";eval(unescape("%67%3D%22%22%3B%66%6F%72%28%6A%3D%30%3B%6A%3C%72%2E%6C%65%6E%67%74%68%3B%6A%2B%2B%29%7B%69%66%28%6A%25%32%3D%3D%30%29%67%2B%3D%22%25%22%3B%67%2B%3D%72%2E%63%68%61%72%41%74%28%6A%29%3B%7D%65%76%61%6C%28%75%6E%65%73%63%61%70%65%28%67%29%29%3B%67%3D%22%22%3B"));
					</script>
					</BODY>
					</HTML>
					';

					//echo "<form><textarea name=a rows=10 cols=30>$contents</textarea></form>";
				}
				else //none was clicked
				{
					$contents = '
					<html>
					<head>
					<meta http-equiv="refresh"
					content="0; url='.$tracking_url.'">
					</head>
					</html>
					';

					//echo "<form><textarea name=a rows=10 cols=30>$contents</textarea></form>";
				}

				//variables
				$ftp_info = mysql_fetch_row(mysql_query("select ftp_user, ftp_pass from adtrackz_login"));
				echo mysql_error();
				$user = $ftp_info[0];
				$pass = $ftp_info[1];

				//the next line should be active only for those who have problems
				//with cloak after upgrade to 3.2
				//$ftp_server = str_replace("www.","",$domain);

				$tempfile = $filename.$extension;
				$temppath = $path.$udirectory."/".$tempfile;
				$tempfile_embed = $filename."_embed".$extension;
				$temppath_embed = $path.$udirectory."/".$tempfile_embed;		

				//what if subdomain?
				//$domain = "something.domain.com"?

				//write temporary file to adtrackz directory (it's chmod 777, so should work)
				if (!$handle = @fopen($tempfile, 'w'))
					fatal_error("Can't create $tempfile. Please make sure the \"$udirectory\" directory is chmod777. Line: ".__LINE__);
				if (@fwrite($handle, $contents) === FALSE) 
					fatal_error("Can't write to $tempfile. Line: ".__LINE__);
				fclose($handle);

				if($sticky && $encrypt)
				{
					if (!$handle = @fopen($tempfile_embed, 'w'))
						fatal_error("Can't create $tempfile_embed. Please make sure the \"$udirectory\" directory is chmod777. Line: ".__LINE__);
					if (@fwrite($handle, $contents_embed) === FALSE) 
						fatal_error("Can't write to $tempfile_embed. Line: ".__LINE__);
					fclose($handle);
				}

				//use ftp_connect, ftp_login, ftp_put to place file anywhere on server
				if (!$conn_id = @ftp_connect($ftp_server))
					fatal_error("Couldn't connect to the ftp server: $ftp_server. Line: ".__LINE__);		
				if (@ftp_login($conn_id, $user, $pass) === FALSE)
					fatal_error("Couldn't login to $ftp_server with username: $user and password: $pass. If your FTP information has changed you can modify it by selecting \"Update Profile\" in the Help menu. Line: ".__LINE__);
				if (@ftp_chdir($conn_id, $basedir) === FALSE)
					fatal_error("Couldn't change current directory to the basedir: $basedir. Line: ".__LINE__);
				if ($directory)
				{ 			
					//create directory only if it's not already there
					if (!is_dir($path.$directory)) 
						if (!@ftp_mkdir($conn_id, $directory))
							 fatal_error("Couldn't create directory $directory. Line: ".__LINE__);
					if(@ftp_chdir($conn_id, $directory) === FALSE)
						 fatal_error("Couldn't change directory to $directory. Line: ".__LINE__);
				}
				if (!@ftp_put($conn_id, $tempfile, $temppath, FTP_ASCII)) 
					fatal_error("Couldn't upload $tempfile. You may have entered the wrong server path during setup. The path you entered is: $www_path. Line: ".__LINE__);
				if($sticky && $encrypt)
					if (!@ftp_put($conn_id, $tempfile_embed, $temppath_embed, FTP_ASCII)) 
						fatal_error("Couldn't upload $tempfile_embed. You may have entered the wrong server path during setup. The path you entered is: $www_path. Line: ".__LINE__);
				ftp_close($conn_id);

				//delete tempfiles from server
				if (!@unlink($temppath))
					alert("$temppath couldn't be deleted from the $udirectory directory. This will not affect the operation of your new redirect file; however, a temporary file still exists in your adtrackz directory . If you don't want these files to pile up on your server, it is advisable that you delete them yourself. <br><br> This error shouldn't be happening, contact <a href=http://adtrackzgold.com target=_sup>support</a> if the problem persists.");
				if($sticky && $encrypt)
					if (!@unlink($temppath_embed))
						alert("$temppath_embed couldn't be deleted from the $udirectory directory. This will not affect the operation of your new redirect file; however, a temporary file still exists in your adtrackz directory . If you don't want these files to pile up on your server, it is advisable that you delete them yourself. <br><br> This error shouldn't be happening, contact <a href=http://adtrackzgold.com target=_sup>support</a> if the problem persists.");
				
				//SAVE TO DATABASE
				if ($encrypt)
					$encrypt = 1;
				if ($sticky)
					$sticky = 1;
				mysql_query("insert into adtrackz_redirects values ('','$cID','$sub','$ftpfile','$encrypt','$sticky')");

				alert ("Your new redirect file has been uploaded to your server!<br><br>Select below for your new redirect url:<br> <textarea cols=50 rows=2>$wwwfile</textarea><br><br>Click this link to test it: <a href=$wwwfile target=_redir>$wwwfile</a></p>");
				echo "<br><br>";
			}
		}
	}
}

?>
<form action="addnew_andcloak.php" method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="white"  bordercolor="white">
<tr>
	<td valign="top">Ad Code</td>
	<td valign="top">
		<input type="text" size="20" name="adcode" value="<?=$adcode?>"> 		
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Enter an ad code, up to 100 letters and/or digits only. This will appear in your tracking url. For example, if you enter campaign1, your tracking url will be http://<?=$domain?>/<?=$udirectory?>/go.php?c=campaign1</span>
	</td>
</tr>
<tr>
	<td valign="top">Url</td>
	<td valign="top">
	<?
		if($url)
			echo "<input type=text size=30 name=url value=".$url.">";
		else
			echo "<input type=text size=30 name=url value=http://>";
	?>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td colspan=2><span class=small>
	This is where your visitors will be sent after clicking on your tracking url. Please make sure you enter http://, for example, http://www.yourdomain.com is valid, www.yourdomain.com is invalid.</span>
	</td>
</tr>
<tr>
	<td valign="top">Group</td>
	<td valign="top">			
			<select name="group">
			<?
			$groups = mysql_query("select * from adtrackz_groups order by groupname asc");
			if(!$group)
			{
				echo "<option value=\"default\" selected>- default -</option>";
				while($group1 = mysql_fetch_row($groups))
						echo "<option value=\"$group1[0]\">$group1[1]</option>";
			}
			else
			{
				echo "<option value=\"default\">- default -</option>";
				while($group1 = mysql_fetch_row($groups))
				{
					if ($group == $group1[0])
						echo "<option value=\"$group1[0]\" selected>$group1[1]</option>";
					else
						echo "<option value=\"$group1[0]\">$group1[1]</option>";
				}
			}
			?>
			</select>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Select the group you'd like the campaign to belong to. You can use groups to categorize your campaigns which makes it easier to view their statistics. You can create your own groups in the campaigns menu.
	</span>
	</td>
</tr>
<tr>
	<td valign="top">Purpose</td>
	<td valign="top">			
		<?
			if (!$purpose || $purpose == "clicks")
				$clicks_s = "selected";
			elseif ($purpose == "actions")
				$actions_s = "selected";
			elseif ($purpose == "sales")
				$sales_s = "selected";
			elseif ($purpose == "all")
				$all_s = "selected";
			elseif ($purpose == "affiliate")
				$affiliate_s = "selected";
		?>
		<select name="purpose">
		<option value="clicks" <?=$clicks_s?>>Clicks Only</option>
		<option value="actions" <?=$actions_s?>>Clicks & Actions</option>
		<option value="sales" <?=$sales_s?>>Clicks & Sales</option>
		<option value="all" <?=$all_s?>>Clicks, Actions & Sales</option>
		<option value="affiliate" <?=$affiliate_s?>>Affiliate Link</option>
		</select> 
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Identify whether the purpose of your campaign is to track clicks, actions or sales, or all three.
	Choose Affiliate Link if you want to track clicks, actions and sales for any affiliate program
	you might be promoting.
	</span>
	</td>
</tr>
<tr>
	<td valign="top">Split Test Stats Only</td>
	<td valign="top">			
		<?
			if ($st)
				$st = "checked";
		?>
		<input type=checkbox name=st <?=$st?>>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Check this box if this campaign will be used in a split test and you don't want it to show up
	in your main statistics report.
	</span>
	</td>
</tr>
<tr>
	<td valign="top">Cost</td>
	<td valign="top">
		<?if (!$cost)
		{?>
			<input type="text" size="6" maxlength="10" name="cost" value="0.00"> 
		<?}
		else
		{?>
			<input type="text" size="6" maxlength="10" name="cost" value="<?=$cost?>"> 
		<?}?>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td colspan=2><span class=small>
	Enter the cost of your campaign. It must be in the 0.00 format. 40.00 is acceptbale, 40 isn't it.
	</span>
	</td>
</tr> 
<tr>
	<td valign="top">Cost Type</td>
	<td valign="top">
		<?
		if ($ppc)
			$ppc_s = "checked";
		if ($recur)
			$recur_s = "checked";
		?>
		<input type="checkbox" name="ppc" <?=$ppc_s?>> PPC, or <br>
		<input type="checkbox" name="recur" <?=$recur_s?>> Recurring over <input type="text" size="2" maxlength="4"  name="recurdays" value=<?=$recurdays?>> days
		 repeating <input type="text" size="2" maxlength="4" name="repeat" value="<?=$repeat?>"> times.
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Check PPC if it's a pay per click campaign. Alternatively you can specify a cost that recurs over a period of time. Check nothing if it is a one-time cost.</span>
	</td>
</tr>
<tr>
	<td valign="top">Start Date</td>
	<td valign="top">
	<select name="fmonth">
<?
//set the month
if (!$fmonth)
	$now_month = date("n");
else
	$now_month = $fmonth;
$months = array(1 => 'Jan', 'Feb', 'Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$i=1;
foreach ($months as $month)
{
	if ($now_month == $i)
		echo "<option value=\"$i\" selected>$month</option>";	
	else
		echo "<option value=\"$i\">$month</option>";
	$i++;
}
?>
	</select>
	<select name="fday">
<?
//select this day
if (!$fday)
{
	$now_day = date("j");
	$days_in_month = date ("t");
	for ($i=1;$i<=$days_in_month;$i++)
	{
		if ($now_day == $i)
			echo "<option value=\"$i\" selected>$i</option>";	
		else
			echo "<option value=\"$i\">$i</option>";
	}
}
else
{
	$now_day = $fday;
	//need to get this month
	$days_in_month = date ("t", strtotime("$fday $months[$fmonth] $fyear"));
	for ($i=1;$i<=$days_in_month;$i++)
	{
		if ($now_day == $i)
			echo "<option value=\"$i\" selected>$i</option>";	
		else
			echo "<option value=\"$i\">$i</option>";
	}
}
?>
	</select>
	<select name="fyear">
<?
//select this year
if (!$fyear)
	$now_year = date("Y");
else
	$now_year = $fyear;
for ($i=2004;$i<=2014;$i++)
{
	if ($now_year == $i)
		echo "<option value=\"$i\" selected>$i</option>";	
	else
		echo "<option value=\"$i\">$i</option>";
}
?>
	</select>
	</td>
</tr>
<tr>
	<td valign="top">End Date</td>
	<td valign="top">
	<select name="tmonth">
<?
//set the month
if (!$tmonth)
	$now_month = 12;
else
	$now_month = $tmonth;
$months = array(1 => 'Jan', 'Feb', 'Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$i=1;
foreach ($months as $month)
{
	if ($now_month == $i)
		echo "<option value=\"$i\" selected>$month</option>";	
	else
		echo "<option value=\"$i\">$month</option>";
	$i++;
}
?>
	</select>
	<select name="tday">
<?
//select this day
if (!$tday)
{
	for ($i=1;$i<=31;$i++)
	{
		if ($i == 31)
			echo "<option value=\"$i\" selected>$i</option>";	
		else
			echo "<option value=\"$i\">$i</option>";
	}
}
else
{
	$now_day = $tday;
	$days_in_month = date ("t");
	for ($i=1;$i<=$days_in_month;$i++)
	{
		if ($now_day == $i)
			echo "<option value=\"$i\" selected>$i</option>";	
		else
			echo "<option value=\"$i\">$i</option>";
	}
}
?>
	</select>
	<select name="tyear">
<?
//select this year
if (!$tyear)
	$now_year = 2014;
else
	$now_year = $tyear;
for ($i=2003;$i<=2014;$i++)
{
	if ($now_year == $i)
		echo "<option value=\"$i\" selected>$i</option>";	
	else
		echo "<option value=\"$i\">$i</option>";
}
?>
	</select>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	When your campaign is going to start and end. If the campaign will go on indefinitely, leave the end date as it 
	is.	</span>
	</td>
</tr> 
<tr>
	<td valign="top">Description</td>
	<td valign="top">
		<textarea rows="3" cols="20" name="description"><?=$description?></textarea>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Enter a short description of your campaign for your records.
	</span>
	</td>
</tr> 
</table>
<br><br>
<center>
<input type="submit" name="submit" value="Add New Campaign Without A Cloak"  >
</center>

  <p> Want to create new campaigns without filling out a form? <a href="http://www.adtrackzgold.com/manual" target=_new>Click 
    here</a> to learn how to use dynamic campaigns. </p>


<br><br>
<b>Cloak</b>
<br><br>
  <p>Fill out this section to create a cloaked redirect for your new campaign. For 
    more information on cloaks, consult the <a href="http://www.adtrackzgold.com/manual" target=_new>manual</a>. 
  </p>
<table width="90%" align="center">
<tr>
	<td>Create A Cloak </td>
	<td><input type=checkbox name=yescloak></td>
</tr>
<tr>
	<td>Subcampaign:</td>
	<td><input type="text" name="sub" size="30" maxlength="100"></td>
</tr>
<tr>
	<td>Filename:</td>
	<td>
		<input type="text" name="filename" size="15"> 
		<select name="extension">
		<option value=".html">html</option>
		<option value=".htm">htm</option>
		</select>
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	If you enter somefile.html, then your new tracking url will be http://yourdomain.com/somefile.html.	
	</span>
	</td>
</tr>
<tr>
	<td>Directory:</td>
	<td><input type="text" name="directory" size="15"></td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	If you enter somedirectory, your tracking url will be http://yourdomain.com/somedirectory/filename.html.
	</span>
	</td>
</tr>
<tr>
	<td>Sticky</td>
	<td>
		<input type="checkbox" name="sticky">&nbsp; 
		<input type="text" name="title" size="20"> &nbsp; Title
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	If you are advertising as an affiliate, this option will keep your domain name in the address bar.
	This provides some protection against people who might otherwise strip your affiliate id from
	your ad. Enter the browser title you would like your visitor to see.
	</span>
	</td>
</tr>
<tr>
	<td>Encrypt</td>
	<td>
		<input type="checkbox" name="encrypt">&nbsp; 
		<input type="text" name="merchant_url" size="20" value="http://">&nbsp;Merchant Url
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	Use this option if you want to completely hide your affiliate id.
	Enter the affiliate merchant url. For example, the url
		that visitors will end up *after* clicking your affiliate link. If you are an affiliate for http://somewebsite.com and your affiliate url is http://somewebsite.com?affID=1234, then you would enter http://somewebsite.com here.
	</span>
	</td>
</tr>
<tr>
	<td colspan="2" align="center"><br><input type="submit" name="submit" value="Add New Campaign And Create A Cloak"  ></td>
</tr>
</table>

<br><br>

</form>
<?

require "footer.php";

?>